<template>
  <a-table size="mini" :loading="tableLoading" :data="tableList" :scroll="{ y: '100%' }" class="table-singe-line show-border-table" :pagination="false">
    <template #columns>
      <a-table-column data-index="eventName" title="操作类型" :width="150" />
      <a-table-column data-index="eventMsg" title="操作内容" />
      <a-table-column data-index="createUname" title="操作人" :width="150" />
      <a-table-column title="操作时间" :width="150">
        <template #cell="{ record }">
          <p>{{ $setTime(record.gmtCreate) }}</p>
        </template>
      </a-table-column>
    </template>
  </a-table>
</template>
<script lang="ts" setup>
  import { ref, onMounted } from 'vue'
  import * as purchaseLogApi from '@/api/logs'
  const props = defineProps({
    currentData: {
      type: Object,
      default: () => {},
    },
    api: {
      type: String,
      default: 'findPurchasePlanLogPage',
    },
  })
  onMounted(() => {
    getTableList()
  })
  const tableList = ref<Array<any>>([])
  const tableLoading = ref(false)

  //日志列表
  async function getTableList() {
    if (!props.currentData.id) return
    tableLoading.value = true
    const res: any = await purchaseLogApi[props.api]({
      billId: props.currentData.id,
      pageSize: 500,
      pageNum: 1,
    })
    tableLoading.value = false
    tableList.value = res?.data?.records || []
  }
</script>
